# coding=utf-8
import time

import allure
from common.assert_operator import *
from common.db import *
from common.read_yaml import *
from common.utils import Utils

string_assert = string_assert() # 字符串校验类
pact = Pact() # 契约校验类
execute_sql = sql() # sql集合
utils = Utils()
data = ReadYaml_By_Root_Dict("case/99_outside_api_test/01_workflow_outside_test/99_01_2_GetProcessStatus_GetCurAuditor_GetProcessEntityByBusiness.yml").get_yaml_data()  # 读取数据

@allure.feature('测试工作流外部接口：获取流程状态、获取责任人、通过业务GUID获取流程实例信息')  # 测试报告显示测试功能
class Test_99_01_2_GetProcessStatus_GetCurAuditor_GetProcessEntityByBusiness():
    """
    测试接口：
    /wf/Api/ProcessEntiy/GetProcessStatus
    /wf/api/ProcessEntiy/GetCurAuditor
    /wf/api/ProcessEntiy/GetProcessEntityByBusiness
    """
    # 获取yml文件中GetProcessStatus的数据参数
    Params = data['GetProcessStatus']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetProcessStatus(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['description']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Outside_Api()    # 进入外部接口类
        user_guid = utils.get_user_guid_by_code(param['user'])    #获取用户guid
        resp = main.GetProcessStatus(param['body'],user_guid)   #发起请求
        dict_assert(expect['response'],resp.json())    # 结果断言

    # 获取yml文件中GetCurAuditor的数据参数
    Params = data['GetCurAuditor']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetCurAuditor(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['description']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Outside_Api()    # 进入外部接口类
        user_guid = utils.get_user_guid_by_code(param['user'])    #获取用户guid
        resp = main.GetCurAuditor(param['body'],user_guid)   #发起请求
        dict_assert(expect['response'],resp.json())    # 结果断言

    # 获取yml文件中GetProcessEntityByBusiness的数据参数
    Params = data['GetProcessEntityByBusiness']
    # 获取yml的title，并作为ids的值传给用例
    ids_list = jsonpath.jsonpath(Params, "$[*][0]")
    @pytest.mark.parametrize("title, param, expect", Params, ids=ids_list)
    def test_GetProcessEntityByBusiness(self, user_login, title, param, expect):
        allure.dynamic.description(f"{param['description']}")  # # 动态解析用例描述在测试报告中展示
        main = user_login.goto_Outside_Api()    # 进入外部接口类
        user_guid = utils.get_user_guid_by_code(param['user'])    #获取用户guid
        resp = main.GetProcessEntityByBusiness(param['body'],user_guid)   #发起请求
        dict_assert(expect['response'],resp.json())    # 结果断言
